module.exports={
    data:{
        comment:{
            commentVal:'',
            isDisabled:false,
            hidden:false,
            focus:false,
            placeholder:''
        },
        commentData:{},
        removeBindtap:0,
        upLoadFlag:1,
        upLoadPage:1,
        likeTabFlag:0
    },
    inputChange:function(e){
        // 监听输入框文字变化，改变发送按钮状态
        var that = this;
        var val = e.detail.value;
        if (val.length > 0 && val != ''){
            that.setData({
                'comment.isDisabled':true
            });
        }else {
             that.setData({
                'comment.isDisabled':false
            });
        }
        
    },
    onCommentShow:function(e){
        // 展示回复弹层
        var that = this;
        
        that['data']['commentData'] = e['currentTarget']['dataset'];
        var placeholder = '';
        if (that['data']['commentData']['nick']) {
            placeholder = '回复 '+ that['data']['commentData']['nick']
        }
        that.setData({
            'comment.hidden':true,
            'comment.isDisabled':false,
            'comment.focus':true,
            'comment.placeholder':placeholder
        });
        that.callback.call(this,'onCommentShow');        
    },
    onCommentHide:function(){
        // 隐藏回复弹层
        var that = this;
        
        that.setData({
            'comment.commentVal':'',
            'comment.hidden':false,
            'comment.focus':false,
            'comment.placeholder': ''
        });
    },
    formSubmit:function(e){
        // 点击发送按钮，触发提交事件
        var val = e.detail.value.textarea,
        that = this;
        that.callback.call(this,'commentContent',val);

        that.setData({
            'comment.commentVal':'',
            'comment.isDisabled':false,
            'comment.hidden':false
        });
    },
    likeFun:function(e){
        // 点赞
        var that = this;
        that.callback.call(this,'likeFun',e.currentTarget.dataset);
    },
    delcommentFun:function(e){
        // 展示二级评论的删除按钮
        var that = this;
        that.callback.call(this,'delcommentFun',e['currentTarget']['dataset']);
        return false;
    },
    removeBindtapFun:function(e){
        // 隐藏二级评论的删除按钮
        var that = this;
        that.callback.call(this,'removeBindtapFun',e['currentTarget']['dataset']);
    },
    delStairComment:function(e){
        // 删除一级评论
        var that = this;
        that.callback.call(this,'delStairComment',e['currentTarget']['dataset']);
    },
    delSecondCommentFun:function(e){
        // 删除二级评论
        var that = this;
        that.callback.call(this,'delSecondComment',e['currentTarget']['dataset']);
    },
    pullUpLoad:function(){
        // 上拉加载
        var that= this;
        if(that.data.upLoadFlag == 0){
            return false;
        }
        that.setData( {
            upLoadPage: that.data.upLoadPage + 1
        })
        that.callback.call(this,'pullUpLoad');
    }
}